package com.pet.mapper;

import com.pet.entity.PetInformation;
import com.pet.entity.institution.PetInstitutionApplication;
import com.pet.entity.institution.PetInstitutionInformation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PetInstitutionMapper {

    /**
     * 查询基地信息
     * @return
     */
    @Select("select * from pet_manage_system.pet_institution_information")
    List<PetInstitutionInformation> selectPetInstitutionInformation();

    /**
     * 查询图片数组
     * @param id
     * @return
     */
    @Select("select img from pet_manage_system.pet_institution_image where institution_id = #{id}")
    List<String> selectInstitutionImage(int id);

    /**
     * 查询机构动物
     * @return
     */
    @Select("select * from pet_manage_system.pet_institution_animal where institution_id = #{id}")
    List<PetInformation> selectPetInformationAnimal(Integer id);

    /**
     * 申请机构
     * @param e
     */
    @Insert("insert into pet_manage_system.pet_institution_application" +
            "(application_user, proof_img, application_declare) " +
            "VALUES " +
            "(#{applicationUser},#{proofImg},#{applicationDeclare})")
    void insertInstitutionApplication(PetInstitutionApplication e);

    @Select("select * from pet_manage_system.pet_institution_application where application_user = #{currentId}")
    PetInstitutionApplication selectApplicationStatus(Long currentId);

    /**
     * 取消机构
     * @param currentId
     */
    @Delete("DELETE FROM pet_manage_system.pet_institution_application WHERE application_user = #{currentId}")
    void deleteApplyInstitution(Long currentId);
}
